<!DOCTYPE html>
<html lang="">

<head>
	<meta name="generator" content="Hugo 0.73.0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="Ap Chen ">
<meta name="description" content="软件缺陷 Error: 人的错误行为导致软件中出现不希望或不可接受的内部状态 Fault: 软件运行时出现不希望或不可接受的状态 Failure: 软件运行时产生了不希望或不可接受的外部" />
<meta name="keywords" content="blog" />
<meta name="robots" content="noodp" />

<link rel="canonical" href="https://fziks.gitee.io/notes/software-enginerring/7-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E5%92%8C%E9%AA%8C%E8%AF%81/" />

<meta itemprop="name" content="7-软件测试和验证">
<meta itemprop="description" content="软件缺陷 Error: 人的错误行为导致软件中出现不希望或不可接受的内部状态 Fault: 软件运行时出现不希望或不可接受的状态 Failure: 软件运行时产生了不希望或不可接受的外部">
<meta itemprop="datePublished" content="2018-11-13T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2018-11-13T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="1238">



<meta itemprop="keywords" content="" />
<meta property="og:title" content="7-软件测试和验证" />
<meta property="og:description" content="软件缺陷 Error: 人的错误行为导致软件中出现不希望或不可接受的内部状态 Fault: 软件运行时出现不希望或不可接受的状态 Failure: 软件运行时产生了不希望或不可接受的外部" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://fziks.gitee.io/notes/software-enginerring/7-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E5%92%8C%E9%AA%8C%E8%AF%81/" />
<meta property="article:published_time" content="2018-11-13T00:00:00+00:00" />
<meta property="article:modified_time" content="2018-11-13T00:00:00+00:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="7-软件测试和验证"/>
<meta name="twitter:description" content="软件缺陷 Error: 人的错误行为导致软件中出现不希望或不可接受的内部状态 Fault: 软件运行时出现不希望或不可接受的状态 Failure: 软件运行时产生了不希望或不可接受的外部"/>


<link rel="apple-touch-icon" sizes="60x60" href="https://fziks.gitee.io/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://fziks.gitee.io/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://fziks.gitee.io/icons/favicon-16x16.png">
<link rel="manifest" href="https://fziks.gitee.io/icons/site.webmanifest">
<link rel="mask-icon" href="https://fziks.gitee.io/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="https://fziks.gitee.io/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<title>7-软件测试和验证</title>


<link rel="stylesheet" href="//at.alicdn.com/t/font_1559566_wk214kwa2dn.css">


    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">



    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI=" crossorigin="anonymous" />
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.css" integrity="sha256-a2tobsqlbgLsWs7ZVUGgP5IvWZsx8bTNQpzsqCSm5mk=" crossorigin="anonymous" />
    
   <link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
    
    
    <link rel="stylesheet" href="https://fziks.gitee.io/sass/main_cdn.min.270b43bb8631af4497ed45b90db42c517e86c9511418de9152f134d02ed32b87.min.2192baea245cf318085511589e62bfbdb3fbe4fb0eef718f1be9af91c10542ce.css" integity="sha256-IZK66iRc8xgIVRFYnmK/vbP75PsO73GPG&#43;mvkcEFQs4=">

</head>

<body style="overflow-x: unset;">
	<div class="container-fluid">
		<div class="row d-print-block">
			<div class="col-12 col-md-3 col-lg-2 bd-sidebar d-print-none">
				<div class="d-flex mt-3 border-bottom">
        <span class="navbar-brand w-100" style="display: grid;">
            <small>
                <a href="https://fziks.gitee.io/" class="text-black-50">
                    <i class="iconfont icon-back-arrow-"></i>
                </a>
                Ap Chen's
            </small>
            <a class="text-dark" href="https://fziks.gitee.io/notes/">
                Notes
            </a>
        </span>
        <button class="btn btn-link text-dark d-md-none p-0 ml-3" type="button" data-toggle="collapse"
            data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="true"
            aria-label="Toggle docs navigation">
            <i class="fad fa-bars"></i>
        </button>
    </div>
				<nav id="bd-docs-nav" class="collapse bd-links">
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/computer-network/">
            
            
                <span class="icontext">S</span>
            
            
            计算机网络
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/operating-system/">
            
            
                <span class="icontext">S</span>
            
            
            操作系统
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/database/">
            
            
                <span class="icontext">S</span>
            
            
            数据库
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/cs50-introduction-to-computer-science/">
            
            
                <span class="icontext">S</span>
            
            
            CS50 MIT
        </a>
    </div>
    
    
    
    <div class="bd-toc-item active bg-light">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/software-enginerring/">
            <i class="iconfont icon-back-arrow-reverse"></i>
            软件工程
        </a>
        <ul class="nav bd-sidenav">
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/1-%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B%E5%BC%95%E8%AE%BA/">1-软件工程引论</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/2-%E8%BD%AF%E4%BB%B6%E8%BF%87%E7%A8%8B%E6%A8%A1%E5%9E%8B/">2-软件过程模型</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/3-%E8%BD%AF%E4%BB%B6%E9%9C%80%E6%B1%82/">3-软件需求与分析</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/4-%E8%BD%AF%E4%BB%B6%E8%AE%BE%E8%AE%A1-sa/">4-软件设计-SA</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/5-%E8%BD%AF%E4%BB%B6%E8%AE%BE%E8%AE%A1-ooad/">5-软件设计-OOAD</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/6-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">6-设计模式</a>
            </li>
            
            
            
            <li class="active">
                <a href="https://fziks.gitee.io/notes/software-enginerring/7-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E5%92%8C%E9%AA%8C%E8%AF%81/">
                    <i class="fad fa-chevron-right mr-1"></i>
                    7-软件测试和验证
                </a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/8-%E8%BD%AF%E4%BB%B6%E7%BB%B4%E6%8A%A4%E5%92%8C%E6%BC%94%E5%8C%96/">8-软件维护和演化</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/software-enginerring/9-%E5%AE%9E%E9%99%85%E5%BC%80%E5%8F%91%E6%B5%81%E7%A8%8B%E6%A1%88%E4%BE%8B/">9-实际开发流程案例</a>
            </li>
            
            
        </ul>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/advanced-programming/">
            
            
                <span class="icontext">A</span>
            
            
            高级程序设计
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/deep-learning/">
            
            
                <span class="icontext">O</span>
            
            
            深度学习基础
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/%E6%96%87%E7%8C%AE%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BF%A1%E6%81%AF%E5%88%86%E6%9E%90/">
            
            
                <span class="icontext">O</span>
            
            
            文献管理与信息分析
        </a>
    </div>
    
    
</nav>
			</div>
			<div class="col-12 col-md-9 col-lg-10 d-print-block">
				<div class="row d-print-block">
					<main class="col-12 col-md-10 col-lg-9 py-md-3 pl-md-5 bd-content d-print-block" role="main">
						<div id="title" class="my-4 border-bottom">
							<span>软件工程</span>
							<h2>7-软件测试和验证</h2>
							<footer>
								<span>
									<i class="iconfont icon-NewFile mr-2"></i>
									2018-11-13 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-modify mr-2"></i>
									2018-11-13 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-copyright mr-2"></i>
									CC BY-NC 4.0
								</span>
							</footer>
						</div>
						<div id="content" class="hl-h2">
							
							
							
							
							
							
							
							
							
							
							
							
							<h2 id="软件缺陷">软件缺陷<a href="#软件缺陷" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>Error: 人的错误行为导致软件中出现不希望或不可接受的内部状态</li>
<li>Fault: 软件运行时出现不希望或不可接受的状态</li>
<li>Failure: 软件运行时产生了不希望或不可接受的外部行为结果</li>
<li>incident: 软件运行中出现了与失效类似的现象</li>
<li>anomaly: 软件运行中出现了未预期的现象</li>
<li>Vulnerability: 能被利用进行攻击的代码缺陷</li>
<li>variance: 软件中于要求不一致处</li>
<li>Defect (Bug): 存在于软件生存期中哪些不希望或不可接受的偏差
<ul>
<li>错误</li>
<li>遗漏</li>
<li>额外实现</li>
</ul>
</li>
<li>因需求产生的缺陷最多</li>
<li>在软件生存期中，缺陷发现和清除的越晚，需付出的代价越大</li>
<li>技术手段
<ul>
<li>需求/设计
<ul>
<li>自然语言：评审</li>
<li>半形式语言（UML）：评审+验证</li>
<li>形式语言：自动验证</li>
</ul>
</li>
<li>代码
<ul>
<li>评审</li>
<li>分析：程序分析</li>
<li>验证：模型检验、推理证明</li>
</ul>
</li>
<li>可执行系统
<ul>
<li>测试：白盒、黑河、灰盒</li>
<li>运行时验证</li>
<li>监控/容错</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="程序分析">程序分析<a href="#程序分析" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>静态分析与动态分析</li>
<li>工具：Coverity, PCLint, Clang, Klocwork</li>
</ul>
<h2 id="软件测试">软件测试<a href="#软件测试" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>测试活动：标识 - 设计 - 开发 - 执行 - 比较</li>
</ul>
<p><img src="https://fziks.gitee.io/images/content/SE-testing.png" alt="软件测试分类"></p>
<ul>
<li>功能测试与非功能测试</li>
</ul>
<h3 id="黑盒方法">黑盒方法<a href="#黑盒方法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<ul>
<li>将测试对象看做黑色盒子，只依据程序的需求规格说明书，检查程序的功能是否符合它的功能说明</li>
<li>穷尽测试：黑盒测试中穷尽所有可能输入条件和输出条件（不可能）</li>
</ul>
<h4 id="等价类划分法">等价类划分法<a href="#等价类划分法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h4>
<ul>
<li>将程序输入域划分为若干部分，每个子集中选取少数具有代表性的数据作为测试用例</li>
<li>有效等价类：检验程序是否实现了规格说明中预先规定的功能和性能</li>
<li>无效等价类：无意义的、不合理的输入数据所构成的集合</li>
<li>标准等价类测试：不考虑无效数据值，测试用例使用每个等价类中的一个值</li>
<li>健壮等价类测试：对无效输入，一个测试用例有一个无效值，其他值均取有效值
<ul>
<li>需要花费精力定义无效测试用例的期望输出</li>
<li>对强类型的语言没有必要考虑无效的输入</li>
</ul>
</li>
<li>测试用例设计
<ul>
<li>
<p>构建等价类表</p>
<p><img src="https://fziks.gitee.io/images/content/SE-equal.png" alt="等价类表例"></p>
</li>
<li>
<p>为每个等价类规定唯一编号</p>
</li>
<li>
<p>设计一个新的测试用例，使它能够尽量覆盖尚未覆盖的有效等价类；直到全覆盖</p>
</li>
<li>
<p>设计一个新的测试用例，使它仅覆盖一个尚未覆盖的无效等价类；直到全覆盖</p>
</li>
</ul>
</li>
</ul>
<h4 id="边界值分析法">边界值分析法<a href="#边界值分析法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h4>
<ul>
<li>在等价类的边界以及两侧的情况设计测试用例</li>
</ul>
<h4 id="因果图法">因果图法<a href="#因果图法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h4>
<ul>
<li>方法步骤
<ul>
<li>根据说明书确定因（输入条件）和过（输出结果），画出因果图</li>
<li>将因果图转换为判定表</li>
<li>为判定表每一列设计一个测试用例</li>
</ul>
</li>
</ul>
<h3 id="白盒方法">白盒方法<a href="#白盒方法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<ul>
<li>循环度量</li>
</ul>
<h4 id="逻辑覆盖与基本路径方法">逻辑覆盖与基本路径方法<a href="#逻辑覆盖与基本路径方法" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h4>
<ul>
<li>语句覆盖：选取足够多的测试数据，使被测试程序中每个语句至少执行一次</li>
<li>判定覆盖：选取足够多的测试数据，使被测试程序中不仅每个语句至少执行一次，而且每个判定的每种可能的结果都至少执行一次</li>
<li>条件覆盖：选取足够多的测试数据，使被测试程序中不 仅每个语句至少执行一次，而且每个判定表达式中的每个条件都取到各种可能的结果</li>
<li>判定/条件覆盖：选取足够多的测试数据，使得判定表达式中的每个条件都取到各种可能的结果，而 且每个判定表达式也都取到各种可能的结果</li>
<li>条件组合覆盖：选取足够多的测试数据，使得判定表达式中条件的各种可能组合都至少出现一次</li>
<li>路径覆盖：选取足够多的测试数据，使得程序的每条可能路径都至少执行一次(若程序图中有环， 则每个环至少经过一次)</li>
<li>路径选择
<ul>
<li>嵌套型：$n$ 个判定语句，$n+1$ 个测试用例</li>
<li>连锁型：$n$ 个判定语句，$2^n$ 个测试用例</li>
</ul>
</li>
<li>循环路径选择
<ul>
<li>简单循环</li>
<li>连锁循环</li>
<li>嵌套循环</li>
<li>非结构循环</li>
</ul>
</li>
</ul>
<h2 id="软件验证">软件验证<a href="#软件验证" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>形式化方法
<ul>
<li>规约</li>
<li>验证：定理证明、模型检验</li>
</ul>
</li>
<li>Kripke Model</li>
</ul>

						</div>
					</main>
					<div class="d-none d-lg-block col-lg-3 bd-toc d-print-none">
						<div class="btn-group-vertical w-100 my-3">
    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="https://list.html" target="_blank">
        <i class="iconfont icon-LC_icon_list_line"></i><br />待更新列表
    </a>
    

    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="mailto:littlegreedy@qq.com"
        target="_blank">
        <i class="iconfont icon-discussion"></i><br />纠错与咨询
    </a>
    
    
    
    
        <a class="btn btn-outline-secondary text-dark w-100 p-2" href="#" onclick="window.print()">
            <i class="iconfont icon-dayin"></i><br />打印本页
        </a>
    
    
</div>
						<h4 class="card-title pb-0">目录</h4>
						<nav id="TableOfContents">
  <ul>
    <li><a href="#软件缺陷">软件缺陷</a></li>
    <li><a href="#程序分析">程序分析</a></li>
    <li><a href="#软件测试">软件测试</a>
      <ul>
        <li><a href="#黑盒方法">黑盒方法</a></li>
        <li><a href="#白盒方法">白盒方法</a></li>
      </ul>
    </li>
    <li><a href="#软件验证">软件验证</a></li>
  </ul>
</nav>
						
						
						<div id="disqus_thread"></div>
							<script>
							

							

							(function() { 
							var d = document, s = d.createElement('script');
							s.src = "https://"+"your site name on disqus"+".disqus.com/embed.js";
							s.setAttribute('data-timestamp', +new Date());
							(d.head || d.body).appendChild(s);
							})();
							</script>
							<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>                  
					  	</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>

	<script
    src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
    crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

<script type="text/javascript" src="https://fziks.gitee.io/custom.min.d3e1b7647f32dbe7e0140398739a26dad3f3470fc1eebe0741ef33668f1b7bd0b2917dc6efb9f0d9f1092b91dca502cab1b883863f02530133a8a8ef609926af.js" integrity="sha512-0&#43;G3ZH8y2&#43;fgFAOYc5om2tPzRw/B7r4HQe8zZo8be9CykX3G77nw2fEJK5HcpQLKsbiDhj8CUwEzqKjvYJkmrw=="></script>
<script type="text/javascript">

document.addEventListener("DOMContentLoaded", function () {
    renderMathInElement(
        document.body, {
            delimiters: [
                {
                    left: "$$",
                    right: "$$",
                    display: true
                },
                {
                    left: "\\[",
                    right: "\\]",
                    display: true
                },
                {
                    left: "$",
                    right: "$",
                    display: false
                },
                {
                    left: "\\(",
                    right: "\\)",
                    display: false
                }
            ],
            strict: false
        }
    );
});


$(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top
    }, 500);
});
</script>




</body>

</html>